﻿using System;
using System.Configuration;
using System.IO;
using System.Web.Services;

namespace Meotom.Upload.v2.Services
{
    /// <summary>
    /// Summary description for ServiceImage
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class ServiceImage : WebService
    {
        [WebMethod]
        public bool DeleteImage(string pathImage)
        {
            try
            {
                var theFile = new FileInfo(ConfigurationManager.AppSettings["UserFolder"] + pathImage);
                if (theFile.Exists)
                {
                    File.Delete(ConfigurationManager.AppSettings["UserFolder"] + pathImage);
                }
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

    }
}
